home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AppleScript - The Beta Release
/
AppleScript - The Beta Release.iso
/
Goodies
/
AutoGuest
/
NoInteractionPatch.a
< prev
next >
Wrap
Text File
|
1991-10-16
|
2KB
|
108 lines
;;
;; 'No User Interaction'-avoidance Patch by Greg Anderson and Michael Gough
;;
;; 17 September 1991
;;
;;
CASE ON
INCLUDE 'Traps.a'
INCLUDE 'PPCToolbox.a'
SEG 'NoInteraction'
;
; Our patch skips over the following code:
;
; if( EvilBackGroundTestIsTrue )
; {
; DisposeHandle( workInProgress );
; *errorResult = eNoUserInteractionAllowed;
; return(0);
; }
;
; To do this, we first intercept all
; calls to DisposHandle:
;
DisposePatch PROC EXPORT
EXPORT OldDisposeAddress
movem.l a1, -(sp)
;
; First we do a little bit of sanity checking to make
; sure that the dispatcher that called us looks like
; the dispatcher we expect to see
;
; 205F225F == move.l (sp)+,A0 followed by move.l (sp)+,A1
;
DispatcherReturnAddressOffset EQU 4
move.l DispatcherReturnAddressOffset(sp), a1
cmpi.l #$205F225F, (a1)
bne.s DefaultDispose
;
; Then we look for the 'eNoUserInteractionAllowed'
; opcode (sp+20 is the return address)
;
ATrapReturnAddressOffset EQU $20
;
; The above C code looks like this once compiled:
;
; _DisposeHandle
; sp+20 -> movea.l $10(a6),a0 (4 bytes)
; move.w #$FD9E,(a0) (4 bytes)
; moveq #0, d0 (2 bytes)
; bra exit (4 bytes)
; ---------
; 14 bytes
;
move.l ATrapReturnAddressOffset(sp), a1
cmpi.w #$FD9E, 6(a1)
bne.s DefaultDispose
;
; To disable this code, we
;
; (a) do not fall through to DisposeHandle
; (b) skip the code that returns eNoUserInteractionAllowed
; by adding a constant (14 decimal) to the return address
;
add #14, a1
move.l a1, ATrapReturnAddressOffset(sp)
;
; Prepare to return to the trap dispatcher
;
movem.l (sp)+, a1
move.l #0, d0
rts
DefaultDispose:
movem.l (sp)+, a1
BackToDispose:
move.l OldDisposeAddress, -(sp)
rts
OldDisposeAddress
dc.l 1
END